define(["jquery", "template", "bbcare"], function ($, template,$bb) {
    var servers={};
    var URL = $bb.baseUrl("followup") + "followup/service";
    //获取题目：
    servers.getParams = function (exam , id){
        return {
            "examinationPaperName":exam,
            "userId":id
        }
    };
    servers.getQuestion = function (params , callback){
        $bb.ajax({
            url: URL + "/patient/evaluation/getAllPostion",
            data: JSON.stringify({
                data: params
            }),
            success: function (data) {
                if(data.success){
                    callback(data);
                }
            }
        });
    };
    //获取分数：
    servers.scoreParams = function (exam , posId ,posSco,userId,taskId){
        posId = posId instanceof Object ? JSON.stringify(posId) : posId;
        posSco = posSco instanceof Object ? JSON.stringify(posSco) : posSco;
        return {
                "examinationPaperName":exam,
                "postionIds":posId,
                "postionScores":posSco,
                "userId":userId,
                'taskId':taskId
        }
    };
    servers.getScore = function (params,callback,otherParams){
        $bb.ajax({
            url: URL + "/patient/evaluation/getScore",
            data: JSON.stringify({
                data: params
            }),
            success: function (data) {
                if(data.success){
                    callback(data,otherParams);
                }else{
                    $bb.toastShow("保存失败",1500);
                }
            }
        });
    };
    //获取历史记录列表：
    servers.hisParams = function(params){
        return {
            "userId": params.userId,
            "examinationPaperName": params.examinationPaperName,
            "taskId":params.taskId
        }
    };
    servers.history = function(params,callback,otherParams){
        $bb.ajax({
            url: URL + "/patient/evaluation/getHistoryScore",
            data: JSON.stringify({
                data: params
            }),
            success: function (data) {
                if(data.success){
                    callback(data,otherParams);
                }
            }
        });
    };
    servers.hashmap = function (){
        function HashMap(){
            this.map = {};
        }
        HashMap.prototype = {
            put : function(key , value){
                this.map[key] = value;
            },
            get : function(key){
                if(this.map.hasOwnProperty(key)){
                    return this.map[key];
                }
                return null;
            },
            remove : function(key){
                if(this.map.hasOwnProperty(key)){
                    return delete this.map[key];
                }
                return false;
            },
            removeAll : function(){
                this.map = {};
            },
            keySet : function(){
                var _keys = [];
                for(var i in this.map){
                    _keys.push(i);
                }
                return _keys;
            }
        };
        HashMap.prototype.constructor = HashMap;
        return HashMap;
    };
    return servers;
});